package com.alks.function.controller.stockdept.pcfactorystockquery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.factoryquery.StitchStockRequest;
import com.alks.function.data.request.finance.salary.SalaryStitchInventoryRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.StitchIORequest;
import com.alks.function.service.stockdept.pcfactorystockquery.IStitchIOService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = {"仓储部-仓储工厂作业-鞋面收发料输入","总经办-工厂查询模块-鞋面收发料查询"})
@RequiredArgsConstructor
@RoleCheck(prgIds = {"160118","170526","130312","180727","160229"})
public class StitchIOController {
    private final IStitchIOService service;

    @PostMapping("/getStitchIOQuery")
    @ApiOperation(value = "收料发料明细-条件查询", tags = "仓储部-仓储工厂作业-鞋面收发料输入")
    public ResponseInfo getStitchIOQuery(@RequestParam@ApiParam("指令") String lotNo) {
        return service.getStitchIOQuery(lotNo);
    }

    @PutMapping("/stitchIOAdd")
    @ApiOperation(value = "收发明细新增-新增", tags = "仓储部-仓储工厂作业-鞋面收发料输入")
    public ResponseInfo stitchIOAdd(@RequestBody StitchIORequest request,
                                    @RequestParam@ApiParam("长度") Integer length) {
        return service.stitchIOAdd(request,length);
    }

    @PutMapping("/stitchIOUp")
    @ApiOperation(value = "收发明细修改-更新", tags = "仓储部-仓储工厂作业-鞋面收发料输入")
    public ResponseInfo stitchIOUp(@RequestBody StitchIORequest request) {
        return service.stitchIOUp(request);
    }

    @PostMapping("/stitchIODetail")
    @ApiOperation(value = "收发明细删除-删除", tags = "仓储部-仓储工厂作业-鞋面收发料输入")
    public ResponseInfo stitchIODetail(@RequestParam@ApiParam("订购单号") String slipNo) {
        return service.stitchIODetail(slipNo);
    }

    @PutMapping("/getStitchDetail")
    @ApiOperation(value = "查询收发明细", tags = "总经办-工厂查询模块-鞋面收发料查询")
    public ResponseInfo getStitchDetail(@RequestBody StitchStockRequest request) {
        return service.getStitchDetail(request);
    }

    @PostMapping("/getStitchDetailExport")
    @ApiOperation(value = "查询收发导出", tags = "总经办-工厂查询模块-鞋面收发料查询")
    public void getStitchDetailExport (@RequestBody StitchStockRequest request, HttpServletResponse response) throws IOException
    {
        service.getStitchDetailExport(request,response);
    }

    @PostMapping("/getStitchSizeDetail")
    @ApiOperation(value = "查询收发号码明细", tags = "总经办-工厂查询模块-鞋面收发料查询")
    public ResponseInfo getStitchSizeDetail(@RequestBody StitchStockRequest request) {
        return service.getStitchSizeDetail(request);
    }
}
